using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Xml;

namespace Mdv.wssAddins.wss
{
    /// <summary>
    /// http://msdn.microsoft.com/en-us/library/aa544268.aspx
    /// </summary>
    [DefaultProperty("Name")]
    public class wssContentType : Model
    {
        #region Properties
        private string _baseType;
        [Browsable(true)]
        [ReadOnly(true)]
        [Category("Reserved")]
        [Description("Reserved for internal use.")]
        public string BaseType
        {
          get { return _baseType; }
          set { _baseType = value; }
        }
        private string _iD;
        [Browsable(true)]
        [Category("Required")]
        [Description("Specifies the content type ID of the content type.")]
        public string ID
        {
            get { return _iD; }
            set { _iD = value; }
        }
        private string _name;
        [Browsable(true)]
        [Category("Required")]
        [Description("Specifies the content type name.")]
        public string Name
        {
            get { return _name; }
            set
            {
                if (String.IsNullOrEmpty(value))
                    throw new ArgumentException("Specify a non-empty argument.", "Name");
                _name = value;
                NodeRenamed();
            }
        }
        private string _group;
        [Browsable(true)]
        [Category("Optional")]
        [Description("Specifies the content type group to which the content type is assigned. Content type groups are user-defined groups that help you organize your columns into logical categories.")]
        public string Group
        {
          get { return _group; }
          set { _group = value; }
        }
        private string _documentTemplate;
        [Browsable(true)]
        [Category("Obsolete")]
        [ReadOnly(true)]
        [Description("")]
        public string DocumentTemplate
        {
            get { return _documentTemplate; }
            set { _documentTemplate = value; }
        }
        private string _resourceFolder;
        [Browsable(true)]
        [Category("Obsolete")]
        [ReadOnly(true)]
        [Description("")]
        public string ResourceFolder
        {
            get { return _resourceFolder; }
            set { _resourceFolder = value; }
        }
        private bool? _readOnly;
        [Browsable(true)]
        [Category("Optional")]
        [Description("TRUE to define the content type as read-only.\n\rIf you do not include this attribute, Windows SharePoint Services treats the content type as if this attributes was set to FALSE.")]
        public bool? ReadOnly
        {
            get { return _readOnly; }
            set { _readOnly = value; }
        }
        private bool? _hidden;
        [Browsable(true)]
        [Category("Optional")]
        [Description("TRUE to define the content type as hidden. If you define a content type as hidden, Windows SharePoint Services does not display that content type on the New button in list views.\n\rIf you do not include this attribute, Windows SharePoint Services treats the content type as if this attributes was set to FALSE.")]
        public bool? Hidden
        {
            get { return _hidden; }
            set { _hidden = value; }
        }
        private string _description;
        [Browsable(true)]
        [Category("Optional")]
        [Description("Provides a description for the content type, to display in the Windows SharePoint Services user interface.")]
        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }
        private bool? _sealed;
        [Browsable(true)]
        [Category("Optional")]
        [Description("TRUE to define the content type as sealed. You must have site collection administrator rights to unseal and edit a content type defined as sealed.\n\rIf you do not include this attribute, Windows SharePoint Services treats the content type as if this attributes was set to FALSE.")]
        public bool? Sealed
        {
            get { return _sealed; }
            set { _sealed = value; }
        }
        private string _v2ListTemplateName;
        [Browsable(true)]
        [Category("Optional")]
        [Description("Specifies the Windows SharePoint Services 2.0 list template type to which this content type maps. For example, the Document content type maps to the Document Library list template.")]
        public string V2ListTemplateName
        {
            get { return _v2ListTemplateName; }
            set { _v2ListTemplateName = value; }
        }
        private int? _version;
        [Browsable(true)]
        [Category("Reserved")]
        [ReadOnly(true)]
        [Description("Reserved for future use.")]
        public int? Version
        {
            get { return _version; }
            set { _version = value; }
        }
        private string _featureId;
        [Browsable(true)]
        [Category("Optional")]
        [Description("Provides the ID of the feature in which the content type is packaged.")]
        public string FeatureId
        {
            get { return _featureId; }
            set { _featureId = value; }
        }
        #endregion
        #region Non-Designer Properties
        private wssFieldRefs _fieldRefs;
        [Browsable(false)]
        public wssFieldRefs FieldRefs
        {
            get { return _fieldRefs; }
        }
        #endregion
        public override string ToString()
        {
            return Name;
        }
        public override void ConstructMap()
        {
            PropertiesToXmlMap.Add("ID", "ID");
            PropertiesToXmlMap.Add("Name", "Name");
            PropertiesToXmlMap.Add("BaseType", "BaseType");
            PropertiesToXmlMap.Add("Description", "Description");
            PropertiesToXmlMap.Add("DocumentTemplate", "DocumentTemplate");
            PropertiesToXmlMap.Add("FeatureId", "FeatureId");
            PropertiesToXmlMap.Add("Group", "Group");
            PropertiesToXmlMap.Add("Hidden", "Hidden");
            PropertiesToXmlMap.Add("ReadOnly", "ReadOnly");
            PropertiesToXmlMap.Add("ResourceFolder", "ResourceFolder");
            PropertiesToXmlMap.Add("Sealed", "Sealed");
            PropertiesToXmlMap.Add("V2ListTemplateName", "V2ListTemplateName");
            PropertiesToXmlMap.Add("Version", "Version");
        }
        public wssContentType()
        {
            Actions = new List<Action>();
            Actions.Add(new Action("Delete", this.Delete));
        }
        public void Delete(ModelEventArgs e)
        {
            NodeDeleted("Name");
        }
    }
}